import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

class Hello {

    public static void main(String[] args) {

        int[] nums = {2, 5, 1, 0, -3};
        System.out.println(Arrays.toString(twoSum(nums, 3)));
        System.out.println(Arrays.toString(twoSum(nums, 10)));

    }

    public static int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int key = target - nums[i];
            if (map.containsKey(key)) {
                return new int[]{map.get(key), i};
            } else {
                map.put(nums[i], i);
            }
        }
        return null;
    }
}